module "matchbox" {
  source = "../modules/matchbox"

  cluster_name             = "${var.cluster_name}"
  matchbox_http_endpoint   = "${var.matchbox_http_endpoint}"
  matchbox_rpc_endpoint    = "${var.matchbox_rpc_endpoint}"
  matchbox_client_cert     = "${var.matchbox_client_cert}"
  matchbox_client_key      = "${var.matchbox_client_key}"
  matchbox_trusted_ca_cert = "${var.matchbox_trusted_ca_cert}"
  ssh_authorized_key       = "${var.ssh_public_key}"

  # configuration
  domain_name          = "${var.network_domain}"
  rhcos_kernel_path    = "${var.rhcos_kernel_path}"
  rhcos_initramfs_path = "${var.rhcos_initramfs_path}"
  rhcos_os_image_url   = "${var.rhcos_os_image_url}"
  rhcos_install_dev    = "${var.rhcos_install_dev}"
  webserver_doc_path   = "${var.webserver_doc_path}"

  # machines
  bootstrap_names = ["bootstrap"]
  bootstrap_mac = "{{ bootstrap_mac }}"
  bootstrap_domains = ["bootstrap.${var.cluster_name}.${var.network_domain}"]
  bootstrap_ign_path = "{{ webserver_doc_path }}/bootstrap.ign"

  master_names   = [
  {% for master in range(master_nodes) %}
    "master-{{ loop.index - 1 }}"{% if loop.index <= master_nodes %},{% endif %}

  {% endfor %}
  ]

  master_macs    = [
    {% for master in range(master_nodes) %}
      "{{ master_macs[ loop.index - 1 ]}}"{% if loop.index <= master_nodes %},{% endif %}

    {% endfor %}
  ]

  master_domains = [
    {% for master in range(master_nodes) %}
      "master-{{ loop.index - 1 }}.{{ cluster_name }}.{{ network_domain }}"{% if loop.index <= master_nodes %},{% endif %}

    {% endfor %}

  ]

  master_ign_path = "{{ webserver_doc_path }}/master.ign"

  worker_names   = [
  {% for worker in range(worker_nodes) %}
    "worker-{{ loop.index - 1 }}"{% if loop.index <= worker_nodes %},{% endif %}

  {% endfor %}
  ]

  worker_macs    = [
    {% for worker in range(worker_nodes) %}
      "{{ worker_macs[ loop.index - 1 ]}}"{% if loop.index <= worker_nodes %},{% endif %}

    {% endfor %}
  ]

  worker_domains = [
    {% for worker in range(worker_nodes) %}
      "worker-{{ loop.index - 1 }}.{{ cluster_name }}.{{ network_domain }}"{% if loop.index <= worker_nodes %},{% endif %}

    {% endfor %}

  ]

  worker_ign_path = "{{ webserver_doc_path }}/worker.ign"
}
